#ifndef CONFIGPARAMS_H
#define CONFIGPARAMS_H

#include <QObject>
#include <QSettings>

class ConfigParams
{
public:
    ConfigParams(){}

    void readFromFile()
    {
        QSettings settings("config.ini", QSettings::IniFormat);
        settings.beginGroup(QString("Basic"));
        mLastCardNum = settings.value("mLastCardNum", "").toString();
        mCorrFileName = settings.value("mCorrFileName", "").toString();
        mLastKValue = settings.value("mLastKValue", 1).toInt();
        mLastCountStart = settings.value("mLastCountStart", 0).toInt();
        mLastCountEnd = settings.value("mLastCountEnd", 0).toInt();
        mLastDistanceX = settings.value("mLastDistanceX", 0).toDouble();
        mLastDistanceY = settings.value("mLastDistanceY", 0).toDouble();
        mLastScaleX = settings.value("mLastScaleX", 0).toDouble();
        mLastScaleY = settings.value("mLastScaleY", 0).toDouble();
        mLastRadius = settings.value("mLastRadius", 1).toDouble();
        mLastLength = settings.value("mLastLength", 1).toDouble();
        settings.endGroup();
    }

    void writeToFile()
    {
        QSettings settings("config.ini", QSettings::IniFormat);
        settings.beginGroup(QString("Basic"));
        settings.setValue("mLastCardNum", mLastCardNum);
        settings.setValue("mCorrFileName", mCorrFileName);
        settings.setValue("mLastKValue", mLastKValue);
        settings.setValue("mLastCountStart", mLastCountStart);
        settings.setValue("mLastCountEnd", mLastCountEnd);
        settings.setValue("mLastDistanceX", mLastDistanceX);
        settings.setValue("mLastDistanceY", mLastDistanceY);
        settings.setValue("mLastScaleX", mLastScaleX);
        settings.setValue("mLastScaleY", mLastScaleY);
        settings.setValue("mLastRadius", mLastRadius);
        settings.setValue("mLastLength", mLastLength);
        settings.endGroup();
    }

    // Getter and Setter for mLastCardNum
    QString getLastCardNum() const { return mLastCardNum; }
    void setLastCardNum(const QString &lastCardNum) { mLastCardNum = lastCardNum; }

    // Getter and Setter for mCorrFileName
    QString getCorrFileName() const { return mCorrFileName; }
    void setCorrFileName(const QString &corrFileName) { mCorrFileName = corrFileName; }

    // Getter and Setter for mLastKValue
    int getLastKValue() const { return mLastKValue; }
    void setLastKValue(int lastKValue) { mLastKValue = lastKValue; }

    int getLastCountStart() const { return mLastCountStart; }
    void setLastCountStart(int start) { mLastCountStart = start; }

    int getLastCountEnd() const { return mLastCountEnd; }
    void setLastCountEnd(int end) { mLastCountEnd = end; }

    // Getter and Setter for mLastDistanceX
    double getLastDistanceX() const { return mLastDistanceX; }
    void setLastDistanceX(double lastDistanceX) { mLastDistanceX = lastDistanceX; }

    // Getter and Setter for mLastDistanceY
    double getLastDistanceY() const { return mLastDistanceY; }
    void setLastDistanceY(double lastDistanceY) { mLastDistanceY = lastDistanceY; }

    // Getter and Setter for mLastScaleX
    double getLastScaleX() const { return mLastScaleX; }
    void setLastScaleX(double lastScaleX) { mLastScaleX = lastScaleX; }

    // Getter and Setter for mLastScaleY
    double getLastScaleY() const { return mLastScaleY; }
    void setLastScaleY(double lastScaleY) { mLastScaleY = lastScaleY; }

    // Getter and Setter for mLastRadius
    double getLastRadius() const { return mLastRadius; }
    void setLastRadius(double lastRadius) { mLastRadius = lastRadius; }

    // Getter and Setter for mLastLength
    double getLastLength() const { return mLastLength; }
    void setLastLength(double lastLength) { mLastLength = lastLength; }

private:
    QString mLastCardNum;//最后一次的控制卡号
    QString mCorrFileName;//校正文件
    int mLastKValue;//K值
    int mLastCountStart;//开始计数
    int mLastCountEnd;//结束计数
    double mLastDistanceX;//行程X
    double mLastDistanceY;//行程Y
    double mLastScaleX;//2D校正因子
    double mLastScaleY;//2D校正因子
    double mLastRadius;//单波半径
    double mLastLength;//打印总长度
};

#endif // CONFIGPARAMS_H
